﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WPFExcelReport
{
    public partial class MainWindow : DocumentBase
    {
        VICC_MKRF vm;
        public MainWindow()
        {
            vm = new VICC_MKRF();
            DataContext = vm;
            InitializeComponent();
            ReSetTab();
            this.Name = "任务管理";
        }
        string CurrentUI = "";

        public override void OnWorkflowIDChange(MessageEventArgs e)
        {
            base.OnWorkflowIDChange(e);
            MessageInfo msg = e.Info;
            string wfid = e.Info.Details;
            ViewBase ui;
            switch (wfid)
            {
                case "AV33SPLIT":
                    if (CurrentUI == wfid)
                        return;
                    CurrentUI = wfid;
                    ui = new TAV33SPLIT();
                    ((TAV33SPLIT)ui).KSTKRS = msg.ART;
                    ((TAV33SPLIT)ui).KST = msg.VAR;
                    ((TAV33SPLIT)ui).AGANG = msg.FARBE;
                    ((TAV33SPLIT)ui).AMTYP = msg.BESCHICH; 
                    MainTab.Children.Add(ui);
                    break;
                case "AVAFKS":
                    if (CurrentUI == wfid)
                        return;
                    CurrentUI = wfid;
                    ui = new TAVAFKS(); 
                    ((TAVAFKS)ui).KSTKRS = msg.ART;
                    ((TAVAFKS)ui).KST = msg.VAR;
                    ((TAVAFKS)ui).AGANG = msg.FARBE;
                    ((TAVAFKS)ui).AMTYP = msg.BESCHICH;
                    MainTab.Children.Add(ui);
                    break;
                case "SGMF02":
                    if (CurrentUI == wfid)
                        return;
                    CurrentUI = wfid;
                    TGMF02 SGMF02 = new TGMF02();
                    SGMF02.KSTKRS = msg.KRS;
                    SGMF02.KST = msg.LFD;
                    SGMF02.AGANG = msg.POS;
                    SGMF02.AMTYP = msg.P2;
                    MainTab.Children.Add(SGMF02);
                    break;
                case "SPRMF03":
                    if (CurrentUI == wfid)
                        return;
                    CurrentUI = wfid;
                    ui = new TPRMF03();
                    ((TPRMF03)ui).KSTKRS = msg.ART;
                    ((TPRMF03)ui).KST = msg.VAR;
                    ((TPRMF03)ui).AGANG = msg.FARBE;
                    ((TPRMF03)ui).AMTYP = msg.BESCHICH;
                    ui.PRTYPE = msg.DESS;
                    MainTab.Children.Add(ui);
                    break;
                case "RL02":
                    if (CurrentUI == wfid)
                        return;
                    CurrentUI = wfid;
                    ui = new TMRILI();
                    ((TMRILI)ui).KSTKRS = msg.ART;
                    ((TMRILI)ui).KST = msg.VAR;
                    ((TMRILI)ui).AGANG = msg.FARBE;
                    ((TMRILI)ui).AMTYP = msg.BESCHICH;
                    ((TMRILI)ui).AMKST = msg.ART+msg.VAR;
                    ui.PRTYPE = msg.DESS;
                    MainTab.Children.Add(ui);
                    break;

            }

        }
        private void ReSetTab()
        {

        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return;
                if (IsLoaded)
                    return;
                IsLoaded = true;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }

    }
}
